package com.zhuiyun.educations.api.rotationimage.mapper;

import com.zhuiyun.educations.api.rotationimage.entity.RotationImage;
import com.zhuiyun.educations.common.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName RotationImageMapper
 * @Description TODO 轮播图持久层
 * @Author 杨友朋
 * @Date 2023/6/21 10:28
 **/
@Mapper
public interface RotationImageMapper extends BaseMapper<RotationImage> {
    /**
    * @Author 杨友朋
    * @Description TODO 全查轮播图信息
    * @Date 2023/6/21 20:46
    * @Return List<RotationImage>
    * @param rotationImage
    */
    @Select("select * from rotation_image where del_flag=0")
    List<RotationImage> selectRotationImage(RotationImage rotationImage);

    /**
    * @Author 杨友朋
    * @Description TODO 根据id删除轮播图信息
    * @Date 2023/6/21 20:46
    * @Return Integer
    * @param id
    */
    @Update("update rotation_image set del_flag=1 where id=#{id}")
    Integer deleteRotationImage(Integer id);

    /**
    * @Author 杨友朋
    * @Description TODO 根据ids批量删除轮播图信息
    * @Date 2023/6/21 20:47
    * @Return Integer
    * @param ids
    */
    @Update("<script>" +
            "update rotation_image set del_flag=1 where id IN " +
            " <foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
            "            #{id}" +
            "        </foreach>" +
            "</script>")
    Integer deleteImageByIds(@Param(value = "ids") List<Integer> ids);
}
